﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Informaiton_Retrieval_Hw3.data
{
    public class ReutersData
    {
        public bool HasTopic
        {
            get;
            set;
        }

        public bool isTopicContent(String str) 
        {
            return Topic.Contains(str);
        }

        //exchanges，orgs，people，places，topics
        /*public bool isExchange 
        {
            get {
                return Exchange != "";
            }
        }

        public bool isOrg
        {
            get
            {
                return Org != "";
            }
        }

        public bool isPeople
        {
            get
            {
                return People != "";
            }
        }

        public bool isPlace
        {
            get
            {
                return Place != "";
            }
        }*/

        public bool isTopic
        {
            get
            {
                return Topic != "";
            }
        }

        public String LewisSplit
        {
            get;
            set;
        }

       /* public String CGISprlit
        {
            get;
            set;
        }

        public int OldId
        {
            get;
            set;
        }

        public int NewId
        {
            get;
            set;
        }

        public String Date
        {
            get;
            set;
        }*/

        public String Topic
        {
            get;
            set;
        }

        /*public String Place
        {
            get;
            set;
        }

        public String People
        {
            get;
            set;
        }

        public String Org
        {
            get;
            set;
        }

        public String Exchange
        {
            get;
            set;
        }

        public String Company
        {
            get;
            set;
        }

        public String Unknown
        {
            get;
            set;
        }*/

        public String Title
        {
            get;
            set;
        }

        /*public String DateLine
        {
            get;
            set;
        }*/

        public String Body
        {
            get;
            set;
        }

        public ReutersData(String data) 
        {
            if (data.Substring(data.IndexOf("TOPICS=") + "TOPICS=".Length + 1, 1) == "Y") HasTopic = true;
            else HasTopic = false;
            
            string[] temp;
            temp = data.Substring(data.IndexOf("LEWISSPLIT=") + "LEWISSPLIT=".Length).Split('"');
            LewisSplit = temp[1];
            //MessageBox.Show(LewisSplit);

            //temp = data.Substring(data.IndexOf("CGISPLIT=") + "CGISPLIT=".Length).Split('"');
            //CGISprlit = temp[1];
            //MessageBox.Show(CGISprlit);

            //temp = data.Substring(data.IndexOf("OLDID=") + "OLDID=".Length).Split('"');
            //OldId = Convert.ToInt32(temp[1]);
            //MessageBox.Show(OldId.ToString());

            //temp = data.Substring(data.IndexOf("NEWID=") + "NEWID=".Length).Split('"');
            //NewId = Convert.ToInt32(temp[1]);
            //MessageBox.Show(NewId.ToString());

            int tagStart,tagEnd;
            //tagStart = data.IndexOf("<DATE>") + "<DATE>".Length;
            //tagEnd = data.IndexOf("</DATE>");
            //if (tagEnd - tagStart <= 0) Date = "";
            //else
            //{
            //    Date = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(Date);

            tagStart = data.IndexOf("<TOPICS>") + "<TOPICS>".Length;
            tagEnd = data.IndexOf("</TOPICS>");
            if (tagEnd - tagStart <= 0) Topic = "";
            else
            {
                Topic = data.Substring(tagStart, tagEnd - tagStart);
            }
            //MessageBox.Show(Topic);

            //tagStart = data.IndexOf("<PLACES>") + "<PLACES>".Length;
            //tagEnd = data.IndexOf("</PLACES>");
            //if (tagEnd - tagStart <= 0) Place = "";
            //else
            //{
            //    Place = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(Place);

            //tagStart = data.IndexOf("<PEOPLE>") + "<PEOPLE>".Length;
            //tagEnd = data.IndexOf("</PEOPLE>");
            //if (tagEnd - tagStart <= 0) People = "";
            //else
            //{
            //   People = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(People);

            //tagStart = data.IndexOf("<ORGS>") + "<ORGS>".Length;
            //tagEnd = data.IndexOf("</ORGS>");
            //if (tagEnd - tagStart <= 0) Org = "";
            //else
            //{
            //    Org = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(Org);

            //tagStart = data.IndexOf("<EXCHANGES>") + "<EXCHANGES>".Length;
            //tagEnd = data.IndexOf("</EXCHANGES>");
            //if (tagEnd - tagStart <= 0) Exchange = "";
            //else
            //{
            //    Exchange = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(Exchange);

            //tagStart = data.IndexOf("<COMPANIES>") + "<COMPANIES>".Length;
            //tagEnd = data.IndexOf("</COMPANIES>");
            //if (tagEnd - tagStart <= 0) Company = "";
            //else
            //{
            //    Company = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(Company);

            //tagStart = data.IndexOf("<UNKNOWN>") + "<UNKNOWN>".Length;
            //tagEnd = data.IndexOf("</UNKNOWN>");
            //if (tagEnd - tagStart <= 0) Unknown = "";
            //else
            //{
            //    Unknown = data.Substring(tagStart, tagEnd - tagStart);
            //}
            
            //MessageBox.Show(Unknown);

            tagStart = data.IndexOf("<TITLE>") + "<TITLE>".Length;
            tagEnd = data.IndexOf("</TITLE>");
            if (tagEnd - tagStart <= 0) Title = "";
            else
            {
                Title = data.Substring(tagStart, tagEnd - tagStart);
            }
            //MessageBox.Show(Title);

            //tagStart = data.IndexOf("<DATELINE>") + "<DATELINE>".Length;
            //tagEnd = data.IndexOf("</DATELINE>");
            //if (tagEnd - tagStart <= 0) DateLine = "";
            //else
            //{
            //    DateLine = data.Substring(tagStart, tagEnd - tagStart);
            //}
            //MessageBox.Show(DateLine);

            tagStart = data.IndexOf("<BODY>") + "<BODY>".Length;
            tagEnd = data.IndexOf("</BODY>");
            if (tagEnd - tagStart <= 0) Body = "";
            else
            {
                Body = data.Substring(tagStart, tagEnd - tagStart);
            }
            //MessageBox.Show(Body);
        }
    }
}
